package com.school.controller;

import com.school.entity.ComplaintInfo;
import com.school.service.ComplaintInfoService;
import com.school.untils.ResultEntity;
import com.school.untils.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "申诉公示信息管理")
@RestController
@RequestMapping("/complaintInfo")
public class ComplaintInfoController {
    @Autowired
    ComplaintInfoService complaintInfoService;

    // 增加
    @ApiOperation("申诉信息增加")
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public ResultEntity addComplaintInfo(@RequestBody ComplaintInfo complaintInfo){
        return  ResultUtils.build(complaintInfoService.addComplaintInfo(complaintInfo));
    }

    // 更新
    @ApiOperation("申诉信息更新")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public ResultEntity updateComplaintInfo(@RequestBody ComplaintInfo complaintInfo){
        return ResultUtils.build(complaintInfoService.updateComplaintInfo(complaintInfo));
    }

    // 根据id查看详情
    @ApiOperation("申诉信息查看详情")
    @GetMapping("/getDetailsById/{id}")
    public ResultEntity getDetailsById(@PathVariable("id") String id){
        return ResultUtils.build(complaintInfoService.getDetailsById(id));
    }

    // 根据id删除
    @ApiOperation("申诉信息删除")
    @DeleteMapping("/delete/{id}")
    public void deleteComplaintInfo(@PathVariable("id") String id){
        complaintInfoService.deleteComplaintInfo(id);
    }

    // 根据条件分页查询
    @ApiOperation("根据条件分页查询")
    @GetMapping("/specificPage")
    public ResultEntity specificPageQueryComplaintInfoList(ComplaintInfo complaintInfo,@RequestParam int page,@RequestParam int size){
        return ResultUtils.build(complaintInfoService.specificPageQueryComplaintInfoList(complaintInfo,page,size));
    }
}
